package com.dailyblue.example.project.bookstore.user.scheduled;

import com.dailyblue.example.project.bookstore.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class CartScheduled {
    @Resource
    private UserService service;

    // @Scheduled(cron = "0 */1 * * * ?")   // 定时器定义，每隔1min执行一次
    @Scheduled(cron = "0 0 3 * * ?") // 定时器定义，每天3点执行一次
    private void process() {
        log.info("开始启动定时器执行同步购物车信息");
        service.syncShoppingCart();
    }
}
